//
//  SchoolCollectionViewCell.m
//  Arts1
//
//  Created by 孤星晨宇 on 15/9/21.
//  Copyright (c) 2015年 Arts1. All rights reserved.
//

#import "SchoolCollectionViewCell.h"
#import <UIImageView+WebCache.h>
#import "AllHeader.h"

@implementation SchoolCollectionViewCell


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.backgroundColor = [UIColor clearColor];
        self.contentView.backgroundColor = [UIColor clearColor];

        UIView *whiteview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH - 20, 80)];
        whiteview.backgroundColor = kRandomColor;
        whiteview.layer.cornerRadius = 4;
        [UIView viewShadowColor:whiteview];
        //  北京图片
        _mainImagewView = [[UIImageView alloc] initWithFrame:whiteview.bounds];
        _mainImagewView.layer.cornerRadius = 4;
        [_mainImagewView setContentMode:(UIViewContentModeScaleAspectFill)];
        _mainImagewView.layer.masksToBounds = YES;
        _mainImagewView.userInteractionEnabled = YES;
        [whiteview addSubview:_mainImagewView];
        
        //  高校名称
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10 , _mainImagewView.height / 2.0 - 17, _mainImagewView.width - 20, 34)];
        _titleLabel.textColor = [UIColor whiteColor];
        _titleLabel.font = [UIFont systemFontOfSize:18];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        [_mainImagewView addSubview:_titleLabel];
        
        [self.contentView addSubview:whiteview];
    }
    return self;
}

- (void)setSchool:(SpaceModel *)school{
    _school = school;
    _titleLabel.text = _school.spaceName;
//    [_mainImagewView sd_setImageWithURL:[NSURL URLWithString:_school.headImg] placeholderImage:nil options:SDWebImageRetryFailed | SDWebImageLowPriority];
    [_mainImagewView sd_setImageWithURL:[NSURL URLWithString:_school.headImg] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        UIImage *bImage = [image boxblurImageWithBlur:0.45];
        _mainImagewView.image = bImage;
    }];
    
}

- (void)setModel:(AttentionSchoolModel *)model
{
    _model = model;
    _titleLabel.text = _model.spaceName;
    [_mainImagewView sd_setImageWithURL:[NSURL URLWithString:_model.headImg] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        UIImage *bImage = [image boxblurImageWithBlur:0.45];
        _mainImagewView.image = bImage;
    }];
}

@end
